package com.eleven.trades.serverimpl;

import com.eleven.trades.entity.Flow;
import com.eleven.trades.mapper.FlowMapper;
import com.eleven.trades.server.FlowServer;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * @author linhaizeng
 */
@Service
public class FlowServerImpl implements FlowServer {

    @Autowired
    FlowMapper flowMapper;

    /**
     * 查询流水记录
     * @param in
     * @return
     */
    @Override
    public List<Flow> selectFlow(String in) {
        try {
            List<Flow> flows = flowMapper.selectByAccountId(in);
            return flows;
        }catch (Exception e){
            return null;
        }
    }

    /**
     * 查询来往交易
     * @param in
     * @param out
     * @return
     */
    @Override
    public List<Flow> selectTransFlow(String  in, String out) {
        try {
            List<Flow> flows = flowMapper.selectByTransId(in, out);
//            System.out.println(in+"|||||||||"+out);
//            List<String> ids = new ArrayList<>();
//            ids.add(in);ids.add(out);
//            QueryWrapper<Flow> qw = new QueryWrapper<>();
//            qw.lambda().in(Flow::getInId,ids).in(Flow::getOutId,ids);
//            List<Flow> flows = flowMapper.selectList(qw);
            return flows;
        }catch (Exception e){
            return null;
        }
    }
}
